package me.youline.dataServer.service.socialAction.event;

import org.springframework.util.Assert;


/**
 * 该类主要提供了发起人和目标对象的设置相关操作，但其还属于比较抽象的层次，子类可以将targetObject具象化。
 * @author linhan
 *
 */
public abstract class AbstractSocialActionEvent implements SocialActionEvent{
	
	private final Long initiator;
	
	protected final Object targetObjct;
	
	public AbstractSocialActionEvent(Long initiator,Object targetObject){
		Assert.notNull(targetObject);
		this.initiator = initiator;
		this.targetObjct = targetObject;
	}
	
	public Long getInitiator() {
		return initiator;
	}

	public Object getTargetObject() {
		return targetObjct;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((initiator == null) ? 0 : initiator.hashCode());
		result = prime * result
				+ ((targetObjct == null) ? 0 : targetObjct.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		AbstractSocialActionEvent other = (AbstractSocialActionEvent) obj;
		if (initiator == null) {
			if (other.initiator != null)
				return false;
		} else if (!initiator.equals(other.initiator))
			return false;
		if (targetObjct == null) {
			if (other.targetObjct != null)
				return false;
		} else if (!targetObjct.equals(other.targetObjct))
			return false;
		return true;
	}
	

}
